package tunafish2k.rpgex.effects;

import net.minecraft.block.Blocks;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectCategory;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.registry.RegistryKeys;
import tunafish2k.rpgex.RpgEX;
import tunafish2k.rpgex.registries.DamageTypeKeys;

public class BleedingEffect extends StatusEffect {

    public BleedingEffect() {
        super(StatusEffectCategory.HARMFUL, 0xFF0000, new net.minecraft.particle.BlockStateParticleEffect(
                ParticleTypes.BLOCK, Blocks.REDSTONE_BLOCK.getDefaultState()));
    }

    @Override
    public boolean canApplyUpdateEffect(int duration, int amplifier) {
        return (duration % 20) == 0;
    }

    @Override
    public boolean applyUpdateEffect(LivingEntity entity, int amplifier) {
        entity.damage(new DamageSource(
                entity.getWorld().getRegistryManager().get(RegistryKeys.DAMAGE_TYPE).entryOf(DamageTypeKeys.BLEED_KEY)),
                1f + amplifier);
        return true;
    }
}
